The coronavirus family causes illnesses ranging from the common cold to more severe diseases such as severe acute respiratory syndrome (SARS) and Middle East respiratory syndrome (MERS).COVID-19 is thought to have originated in a seafood market where wildlife was sold illegally.The WHO declared the virus a pandemic on March 11 and said it was "deeply concerned by the alarming levels of spread and severity" of the outbreak.Scientists have pointed to either bats or snakes as possible sources. This notebook aims at exploring COVID-19 through data analysis and future predictions.



Data is provided by Johns Hopkins University
Learn more from the WHO
Learn more from the CDC

Source: https://cdn.pixabay.com/photo/2020/03/08/23/24/coronavirus-4914028_1280.jpg

TRANSMISSION OF CORONA VIRUS:
Corona virus are mostly spread from infected person through talks, cough, sneezes (discharge of saliva drops) and also from hand shake with infected person.


Timeline of corona virus:



SYMPTOMS OF CORONAVIRUS

  • Fever
  • Dry cough
  • Sore throat
  • Nasal mobbing

  • </font>

    Source: https://cdn.pixabay.com/photo/2020/04/16/04/54/quarantine-5049106_1280.png

    Keep strong, world! Stay safe and healthy.

    In [1]:
    import numpy as np 
    import pandas as pd 
    import matplotlib.pyplot as plt 
    import matplotlib.colors as mcolors
    import math
    import time
    from sklearn.linear_model import LinearRegression
    from sklearn.model_selection import train_test_split
    import datetime
    import operator 
    plt.style.use('fivethirtyeight')
    
    
    import plotly.graph_objects as go
    
    import pycountry
    import plotly.express as px
    
    In [2]:
    confirmed_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv')
    deaths_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv')
    recoveries_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv')
    latest_data = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/07-16-2020.csv')
    
    In [17]:
    #confirmed_df.head()
    
    In [34]:
    india_specific = confirmed_df[confirmed_df['Country/Region']=="India"]
    #india_specific
    
    In [19]:
    #deaths_df.head()
    
    In [20]:
    #recoveries_df.head()
    
    In [21]:
    #latest_data.head()
    
    In [22]:
    cols = confirmed_df.keys()
    
    In [35]:
    #getting the dates
    confirmed = confirmed_df.loc[:, cols[4]:cols[-1]]
    deaths = deaths_df.loc[:, cols[4]:cols[-1]]
    recoveries = recoveries_df.loc[:, cols[4]:cols[-1]]
    india_dates = india_specific.loc[:,cols[4]:cols[-1]]
    
    In [36]:
    dates = confirmed.keys()
    world_cases = []
    total_deaths = [] 
    mortality_rate = []
    recovery_rate = [] 
    total_recovered = [] 
    total_active = [] 
    india_new = []
    
    china_cases = [] 
    italy_cases = []
    us_cases = [] 
    brazil_cases = []
    india_cases = []
    
    china_deaths = [] 
    italy_deaths = []
    us_deaths = [] 
    brazil_deaths = [] 
    india_deaths = []
    
    china_recoveries = [] 
    italy_recoveries = []
    us_recoveries = [] 
    brazil_recoveries = [] 
    india_recoveries = [] 
    
    for i in dates:
        confirmed_sum = confirmed[i].sum()
        death_sum = deaths[i].sum()
        recovered_sum = recoveries[i].sum()
        india_sum = india_dates[i].sum()
        
        # confirmed, deaths, recovered, and active
        world_cases.append(confirmed_sum)
        total_deaths.append(death_sum)
        total_recovered.append(recovered_sum)
        total_active.append(confirmed_sum-death_sum-recovered_sum)
        india_new.append(india_sum)
        
        # calculate rates
        mortality_rate.append(death_sum/confirmed_sum)
        recovery_rate.append(recovered_sum/confirmed_sum)
    
        # case studies 
        china_cases.append(confirmed_df[confirmed_df['Country/Region']=='China'][i].sum())
        italy_cases.append(confirmed_df[confirmed_df['Country/Region']=='Italy'][i].sum())
        us_cases.append(confirmed_df[confirmed_df['Country/Region']=='US'][i].sum())
        brazil_cases.append(confirmed_df[confirmed_df['Country/Region']=='Brazil'][i].sum())
        india_cases.append(confirmed_df[confirmed_df['Country/Region']=='India'][i].sum())
        
        
        china_deaths.append(deaths_df[deaths_df['Country/Region']=='China'][i].sum())
        italy_deaths.append(deaths_df[deaths_df['Country/Region']=='Italy'][i].sum())
        us_deaths.append(deaths_df[deaths_df['Country/Region']=='US'][i].sum())
        brazil_deaths.append(deaths_df[deaths_df['Country/Region']=='Brazil'][i].sum())
        india_deaths.append(deaths_df[deaths_df['Country/Region']=='India'][i].sum())
        
        china_recoveries.append(recoveries_df[recoveries_df['Country/Region']=='China'][i].sum())
        italy_recoveries.append(recoveries_df[recoveries_df['Country/Region']=='Italy'][i].sum())
        us_recoveries.append(recoveries_df[recoveries_df['Country/Region']=='US'][i].sum())
        brazil_recoveries.append(recoveries_df[recoveries_df['Country/Region']=='Brazil'][i].sum())
        india_recoveries.append(recoveries_df[recoveries_df['Country/Region']=='India'][i].sum())
    
    In [37]:
    #daily increase
    
    def daily_increase(data):
        d = [] 
        for i in range(len(data)):
            if i == 0:
                d.append(data[0])
            else:
                d.append(data[i]-data[i-1])
        return d 
    
    # confirmed cases
    world_daily_increase = daily_increase(world_cases)
    china_daily_increase = daily_increase(china_cases)
    italy_daily_increase = daily_increase(italy_cases)
    us_daily_increase = daily_increase(us_cases)
    brazil_daily_increase = daily_increase(brazil_cases)
    india_daily_increase = daily_increase(india_cases)
    
    # deaths
    world_daily_death = daily_increase(total_deaths)
    china_daily_death = daily_increase(china_deaths)
    italy_daily_death = daily_increase(italy_deaths)
    us_daily_death = daily_increase(us_deaths)
    brazil_daily_death = daily_increase(brazil_deaths)
    india_daily_death = daily_increase(india_deaths)
    
    
    # recoveries
    world_daily_recovery = daily_increase(total_recovered)
    china_daily_recovery = daily_increase(china_recoveries)
    italy_daily_recovery = daily_increase(italy_recoveries)
    us_daily_recovery = daily_increase(us_recoveries)
    brazil_daily_recovery = daily_increase(brazil_recoveries)
    india_daily_recovery = daily_increase(india_recoveries)
    
    In [38]:
    days_since_1_22 = np.array([i for i in range(len(dates))]).reshape(-1, 1)
    world_cases = np.array(world_cases).reshape(-1, 1)
    total_deaths = np.array(total_deaths).reshape(-1, 1)
    total_recovered = np.array(total_recovered).reshape(-1, 1)
    india_new = np.array(india_new).reshape(-1, 1)
    
    In [39]:
    #futue
    
    days_in_future = 10
    future_forcast = np.array([i for i in range(len(dates)+days_in_future)]).reshape(-1, 1)
    adjusted_dates = future_forcast[:-10]
    
    In [40]:
    start = '1/22/2020'
    start_date = datetime.datetime.strptime(start, '%m/%d/%Y')
    future_forcast_dates = []
    for i in range(len(future_forcast)):
        future_forcast_dates.append((start_date + datetime.timedelta(days=i)).strftime('%m/%d/%Y'))
    

    World Graph with cases:

    In [3]:
    new_graph = confirmed_df[["Province/State","Lat","Long","Country/Region"]]
    new_graph.rename(columns={'Country/Region':'Country_Region'}, inplace=True)
    new_graph.rename(columns={'Province/State	':'Province_State	'}, inplace=True)
    df_temp = latest_data.copy()
    df_temp['Country_Region'].replace({'Mainland China': 'China'}, inplace=True)
    df_latlong = pd.merge(df_temp, new_graph, on=["Country_Region"])
    
    c:\users\dell\appdata\local\programs\python\python38-32\lib\site-packages\pandas\core\frame.py:4125: SettingWithCopyWarning: 
    A value is trying to be set on a copy of a slice from a DataFrame
    
    See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
      return super().rename(
    
    In [4]:
    fig = px.density_mapbox(df_latlong, 
                            lat="Lat_x", 
                            lon="Long_", 
                            hover_name="Country_Region", 
                            hover_data=["Confirmed","Deaths","Recovered"], 
                            animation_frame="Last_Update",
                            color_continuous_scale="Portland",
                            radius=7, 
                            zoom=0,height=700)
    fig.update_layout(title='Worldwide Corona Virus Cases Time Lapse - Confirmed, Deaths, Recovered',
                      font=dict(family="Courier New, monospace",
                                size=18,
                                color="#7f7f7f")
                     )
    fig.update_layout(mapbox_style="open-street-map", mapbox_center_lon=0)
    fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
    
    
    fig.show()
    
    In [43]:
    adjusted_dates = adjusted_dates.reshape(1, -1)[0]
    
    plt.figure(figsize=(16, 9))
    plt.bar(adjusted_dates, world_daily_increase)
    plt.title('World Daily Increases in Confirmed Cases', size=30)
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('# of Cases', size=30)
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    
    plt.figure(figsize=(16, 9))
    plt.bar(adjusted_dates, world_daily_death)
    plt.title('World Daily Increases in Confirmed Deaths', size=30)
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('# of Cases', size=30)
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    
    plt.figure(figsize=(16, 9))
    plt.bar(adjusted_dates, world_daily_recovery)
    plt.title('World Daily Increases in Confirmed Recoveries', size=30)
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('# of Cases', size=30)
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    
    In [44]:
    def country_plot(x, y1, y2, y3, y4, country):
        plt.figure(figsize=(16, 9))
        plt.plot(x, y1)
        plt.title('{} Confirmed Cases'.format(country), size=30)
        plt.xlabel('Days Since 1/22/2020', size=30)
        plt.ylabel('# of Cases', size=30)
        plt.xticks(size=20)
        plt.yticks(size=20)
        plt.show()
    
        plt.figure(figsize=(16, 9))
        plt.bar(x, y2)
        plt.title('{} Daily Increases in Confirmed Cases'.format(country), size=30)
        plt.xlabel('Days Since 1/22/2020', size=30)
        plt.ylabel('# of Cases', size=30)
        plt.xticks(size=20)
        plt.yticks(size=20)
        plt.show()
    
        plt.figure(figsize=(16, 9))
        plt.bar(x, y3)
        plt.title('{} Daily Increases in Deaths'.format(country), size=30)
        plt.xlabel('Days Since 1/22/2020', size=30)
        plt.ylabel('# of Cases', size=30)
        plt.xticks(size=20)
        plt.yticks(size=20)
        plt.show()
    
        plt.figure(figsize=(16, 9))
        plt.bar(x, y4)
        plt.title('{} Daily Increases in Recoveries'.format(country), size=30)
        plt.xlabel('Days Since 1/22/2020', size=30)
        plt.ylabel('# of Cases', size=30)
        plt.xticks(size=20)
        plt.yticks(size=20)
        plt.show()
    

    Graphing the number of confirmed cases, active cases, deaths, recoveries, mortality rate (CFR), and recovery rate

    In [45]:
    country_plot(adjusted_dates, china_cases, china_daily_increase, china_daily_death, china_daily_recovery, 'China')
    
    In [46]:
    country_plot(adjusted_dates, italy_cases, italy_daily_increase, italy_daily_death, italy_daily_recovery, 'Italy')
    
    In [47]:
    country_plot(adjusted_dates, us_cases, us_daily_increase, us_daily_death, us_daily_recovery, 'United States')
    
    In [48]:
    country_plot(adjusted_dates, brazil_cases, brazil_daily_increase, brazil_daily_death, brazil_daily_recovery, 'Brazil')
    
    In [49]:
    country_plot(adjusted_dates, india_cases, india_daily_increase, india_daily_death, india_daily_recovery, 'India')
    

    Comparision of Top 5 affected countries

    In [50]:
    plt.figure(figsize=(16, 9))
    plt.plot(adjusted_dates, china_cases)
    plt.plot(adjusted_dates, italy_cases)
    plt.plot(adjusted_dates, us_cases)
    plt.plot(adjusted_dates, brazil_cases)
    plt.plot(adjusted_dates, india_cases)
    
    plt.title('# of Coronavirus Cases', size=30)
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('# of Cases', size=30)
    plt.legend(['China', 'Italy', 'US', 'Brazil', 'India'], prop={'size': 20})
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    
    plt.figure(figsize=(16, 9))
    plt.plot(adjusted_dates, china_deaths)
    plt.plot(adjusted_dates, italy_deaths)
    plt.plot(adjusted_dates, us_deaths)
    plt.plot(adjusted_dates, brazil_deaths)
    plt.plot(adjusted_dates, india_deaths)
    
    plt.title('# of Coronavirus Deaths', size=30)
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('# of Cases', size=30)
    plt.legend(['China', 'Italy', 'US', 'Brazil', 'India'], prop={'size': 20})
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    
    plt.figure(figsize=(16, 9))
    plt.plot(adjusted_dates, china_recoveries)
    plt.plot(adjusted_dates, italy_recoveries)
    plt.plot(adjusted_dates, us_recoveries)
    plt.plot(adjusted_dates, brazil_recoveries)
    plt.plot(adjusted_dates, india_recoveries)
    
    plt.title('# of Coronavirus Recoveries', size=30)
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('# of Cases', size=30)
    plt.legend(['China', 'Italy', 'US','Brazil', 'India'], prop={'size': 20})
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    

    Model for predicting # of confirmed cases using Machine Learning . I am using Kernelized support vector machine(SVM), PloynomialFeature with Ridge regression and Decision Tree .

    Prediction of WORLD CASES using Kernelized support vector machine(SVM) output:

    In [51]:
    # Kernelized Support Vector Machine(SVM)
    
    from sklearn.svm import SVR
    from sklearn.preprocessing import MinMaxScaler
    scaler = MinMaxScaler()
    
    X_train_confirmed, X_test_confirmed, y_train_confirmed, y_test_confirmed = train_test_split(days_since_1_22[60:] , world_cases[60:] , test_size=0.20, shuffle=False) 
    
    X_train_scaled = scaler.fit_transform(X_train_confirmed)
    X_test_scaled = scaler.transform(X_test_confirmed)
    
    svm_confirmed = SVR(shrinking=True, kernel='poly',gamma=0.01, epsilon=1,degree=3, C=0.1)
    svm_confirmed.fit(X_train_confirmed, y_train_confirmed)
    svm_pred = svm_confirmed.predict(future_forcast)
    svm_test_pred = svm_confirmed.predict(X_test_confirmed)
    
    
    print("")
    print("Training score:")
    print(svm_confirmed.score(X_train_confirmed, y_train_confirmed))
    print("")
    
    print("Test score:")
    print(svm_confirmed.score(X_test_confirmed, y_test_confirmed))
    
    plt.plot(y_test_confirmed)
    plt.plot(svm_test_pred)
    plt.legend(['Test Data', 'SVM Predictions'])
    
    Training score:
    0.9748949453028364
    
    Test score:
    0.9974497559599237
    
    c:\users\dell\appdata\local\programs\python\python38-32\lib\site-packages\sklearn\utils\validation.py:73: DataConversionWarning:
    
    A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
    
    
    Out[51]:
    <matplotlib.legend.Legend at 0x14d798b0>

    Prediction of WORLD CASES using PloynomialFeature with Ridge regression output:

    In [52]:
    #Polynomial feature regression model prediction
    
    from sklearn.linear_model import Ridge
    from sklearn.preprocessing import PolynomialFeatures
    
    
    X_train_confirmed, X_test_confirmed, y_train_confirmed, y_test_confirmed = train_test_split(days_since_1_22[60:] , world_cases[60:] , test_size=0.20, shuffle=False) 
    
    poly = PolynomialFeatures(degree=4)
    poly_X_train_confirmed = poly.fit_transform(X_train_confirmed)
    poly_X_test_confirmed = poly.fit_transform(X_test_confirmed)
    poly_future_forcast = poly.fit_transform(future_forcast)
    
    linreg = Ridge().fit(poly_X_train_confirmed, y_train_confirmed)
    test_linear_pred = linreg.predict(poly_X_test_confirmed)
    linear_pred = linreg.predict(poly_future_forcast)
    
    print("Training score:")
    print(linreg.score(poly_X_train_confirmed, y_train_confirmed))
    print("")
    print("Test score:")
    print(linreg.score(poly_X_test_confirmed, y_test_confirmed))
    
    plt.plot(y_test_confirmed)
    plt.plot(test_linear_pred)
    plt.legend(['Test Data', 'Polynomial feature Predictions'])
    
    Training score:
    0.9999142504673255
    
    Test score:
    0.9850424712566502
    
    c:\users\dell\appdata\local\programs\python\python38-32\lib\site-packages\sklearn\linear_model\_ridge.py:147: LinAlgWarning:
    
    Ill-conditioned matrix (rcond=4.47811e-19): result may not be accurate.
    
    
    Out[52]:
    <matplotlib.legend.Legend at 0x14fb04f0>

    Prediction of INDIAN CASES using PloynomialFeature with Ridge regression.

    In [53]:
    #Polynomial feature regression model prediction of india only
    
    from sklearn.linear_model import Ridge
    from sklearn.preprocessing import PolynomialFeatures
    
    
    X_train, X_test, y_train, y_test = train_test_split(days_since_1_22[10:], india_new[10:] , test_size=0.20, shuffle=False) 
    
    poly = PolynomialFeatures(degree=5)
    poly1_X_train = poly.fit_transform(X_train)
    poly1_X_test = poly.fit_transform(X_test)
    poly1_future_forcast = poly.fit_transform(future_forcast)
    
    linreg = Ridge().fit(poly1_X_train, y_train)
    test1_linear_pred = linreg.predict(poly1_X_test)
    linear1_pred = linreg.predict(poly1_future_forcast)
    
    print("Training score:")
    print(linreg.score(poly1_X_train, y_train))
    print("")
    print("Test score:")
    print(linreg.score(poly1_X_test, y_test))
    
    plt.plot(y_test)
    plt.plot(test1_linear_pred)
    plt.legend(['Test Data', 'Polynomial feature Predictions of india'])
    
    Training score:
    0.9999122199651325
    
    Test score:
    0.9971795148454188
    
    c:\users\dell\appdata\local\programs\python\python38-32\lib\site-packages\sklearn\linear_model\_ridge.py:147: LinAlgWarning:
    
    Ill-conditioned matrix (rcond=3.05543e-23): result may not be accurate.
    
    
    Out[53]:
    <matplotlib.legend.Legend at 0x1746c520>
    In [54]:
    def plot_predictions(x, y, pred, algo_name, color):
        plt.figure(figsize=(16, 9))
        plt.plot(x, y)
        plt.plot(future_forcast, pred, linestyle='dashed', color=color)
        plt.title('# of Coronavirus Cases Over Time', size=30)
        plt.xlabel('Days Since 1/22/2020', size=30)
        plt.ylabel('# of Cases', size=30)
        plt.legend(['Confirmed Cases', algo_name], prop={'size': 20})
        plt.xticks(size=20)
        plt.yticks(size=20)
        plt.show()
    

    Predictions for confirmed coronavirus cases worldwide

    In [55]:
    plot_predictions(adjusted_dates, world_cases, svm_pred, 'SVM Predictions', 'purple')
    
    In [56]:
    plot_predictions(adjusted_dates, world_cases, linear_pred, 'Polynomial Regression Predictions', 'orange')
    

    Predictions for confirmed coronavirus cases India

    In [57]:
    plot_predictions(adjusted_dates, india_new, linear1_pred, 'Polynomial Regression Predictions of India', 'red')
    

    Future predictions using SVM for next 10 days worldwide:

    In [58]:
    # Future predictions using SVM 
    svm_df = pd.DataFrame({'Date': future_forcast_dates[-10:], 'SVM Predicted # of Confirmed Cases Worldwide': np.round(svm_pred[-10:])})
    svm_df
    
    Out[58]:
    Date SVM Predicted # of Confirmed Cases Worldwide
    0 07/18/2020 14113323.0
    1 07/19/2020 14336393.0
    2 07/20/2020 14561969.0
    3 07/21/2020 14790065.0
    4 07/22/2020 15020695.0
    5 07/23/2020 15253875.0
    6 07/24/2020 15489616.0
    7 07/25/2020 15727934.0
    8 07/26/2020 15968842.0
    9 07/27/2020 16212355.0

    Future predictions polynomial regression for next 10 days worldwide:

    In [59]:
    # Future predictions using polynomial regression
    linear_pred = linear_pred.reshape(1,-1)[0]
    svm_df = pd.DataFrame({'Date': future_forcast_dates[-10:], 'Polynomial Predicted # of Confirmed Cases Worldwide': np.round(linear_pred[-10:])})
    svm_df
    
    Out[59]:
    Date Polynomial Predicted # of Confirmed Cases Worldwide
    0 07/18/2020 14698288.0
    1 07/19/2020 14979717.0
    2 07/20/2020 15267043.0
    3 07/21/2020 15560382.0
    4 07/22/2020 15859852.0
    5 07/23/2020 16165569.0
    6 07/24/2020 16477652.0
    7 07/25/2020 16796223.0
    8 07/26/2020 17121402.0
    9 07/27/2020 17453313.0

    Future predictions using ploynomialfeature for next 10 days India:

    In [60]:
    # Future predictions using polynomial regression of india
    linear1_pred = linear1_pred.reshape(1,-1)[0]
    svm_df = pd.DataFrame({'Date': future_forcast_dates[-10:], 'Polynomial Predicted # of Confirmed Cases India': np.round(linear1_pred[-10:])})
    svm_df
    
    Out[60]:
    Date Polynomial Predicted # of Confirmed Cases India
    0 07/18/2020 1036291.0
    1 07/19/2020 1066670.0
    2 07/20/2020 1097721.0
    3 07/21/2020 1129451.0
    4 07/22/2020 1161872.0
    5 07/23/2020 1194995.0
    6 07/24/2020 1228828.0
    7 07/25/2020 1263383.0
    8 07/26/2020 1298670.0
    9 07/27/2020 1334700.0

    Mortality rate:

    In [61]:
    mean_mortality_rate = np.mean(mortality_rate)
    plt.figure(figsize=(16, 9))
    plt.plot(adjusted_dates, mortality_rate, color='orange')
    plt.axhline(y = mean_mortality_rate,linestyle='--', color='black')
    plt.title('Mortality Rate of Coronavirus Over Time', size=30)
    plt.legend(['mortality rate', 'y='+str(mean_mortality_rate)], prop={'size': 20})
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('Mortality Rate', size=30)
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    

    Recovery rate:

    In [62]:
    mean_recovery_rate = np.mean(recovery_rate)
    plt.figure(figsize=(16, 9))
    plt.plot(adjusted_dates, recovery_rate, color='blue')
    plt.axhline(y = mean_recovery_rate,linestyle='--', color='black')
    plt.title('Recovery Rate of Coronavirus Over Time', size=30)
    plt.legend(['recovery rate', 'y='+str(mean_recovery_rate)], prop={'size': 20})
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('Recovery Rate', size=30)
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    

    Death vs Recovery :

    In [63]:
    plt.figure(figsize=(16, 9))
    plt.plot(adjusted_dates, total_deaths, color='r')
    plt.plot(adjusted_dates, total_recovered, color='green')
    plt.legend(['death', 'recoveries'], loc='best', fontsize=20)
    plt.title('# of Coronavirus Cases', size=30)
    plt.xlabel('Days Since 1/22/2020', size=30)
    plt.ylabel('# of Cases', size=30)
    plt.xticks(size=20)
    plt.yticks(size=20)
    plt.show()
    
    In [64]:
    unique_countries =  list(latest_data['Country_Region'].unique())
    country_confirmed_cases = []
    country_death_cases = [] 
    country_active_cases = []
    country_recovery_cases = []
    country_mortality_rate = [] 
    
    no_cases = []
    for i in unique_countries:
        cases = latest_data[latest_data['Country_Region']==i]['Confirmed'].sum()
        if cases > 0:
            country_confirmed_cases.append(cases)
        else:
            no_cases.append(i)
            
    for i in no_cases:
        unique_countries.remove(i)
        
    # sort countries by the number of confirmed cases
    unique_countries = [k for k, v in sorted(zip(unique_countries, country_confirmed_cases), key=operator.itemgetter(1), reverse=True)]
    for i in range(len(unique_countries)):
        country_confirmed_cases[i] = latest_data[latest_data['Country_Region']==unique_countries[i]]['Confirmed'].sum()
        country_death_cases.append(latest_data[latest_data['Country_Region']==unique_countries[i]]['Deaths'].sum())
        country_recovery_cases.append(latest_data[latest_data['Country_Region']==unique_countries[i]]['Recovered'].sum())
        country_active_cases.append(country_confirmed_cases[i] - country_death_cases[i] - country_recovery_cases[i])
        country_mortality_rate.append(country_death_cases[i]/country_confirmed_cases[i])
    

    Coronavirus data country wise:

    In [65]:
    country_df = pd.DataFrame({'Country Name': unique_countries, 'Number of Confirmed Cases': country_confirmed_cases,
                              'Number of Deaths': country_death_cases, 'Number of Recoveries' : country_recovery_cases, 
                              'Number of Active Cases' : country_active_cases,
                              'Mortality Rate': country_mortality_rate})
    # number of cases per country/region
    
    country_df.style.background_gradient(cmap='Greens')
    
    Out[65]:
    Country Name Number of Confirmed Cases Number of Deaths Number of Recoveries Number of Active Cases Mortality Rate
    0 US 3576157 138358 1090645 2347154 0.038689
    1 Brazil 2012151 76688 1397531 537932 0.038112
    2 India 1003832 25602 635757 342473 0.025504
    3 Russia 751612 11920 530801 208891 0.015859
    4 Peru 341586 12615 230994 97977 0.036931
    5 South Africa 324221 4669 165591 153961 0.014401
    6 Mexico 324041 37574 257681 28786 0.115954
    7 Chile 323698 7290 295301 21107 0.022521
    8 United Kingdom 294116 45204 1403 247509 0.153694
    9 Iran 267061 13608 230608 22845 0.050955
    10 Spain 258855 28416 150376 80063 0.109776
    11 Pakistan 257914 5426 178737 73751 0.021038
    12 Italy 243736 35017 196246 12473 0.143668
    13 Saudi Arabia 243238 2370 187622 53246 0.009744
    14 Turkey 216873 5440 198820 12613 0.025084
    15 France 211102 30141 79161 101800 0.142779
    16 Germany 201450 9087 186400 5963 0.045108
    17 Bangladesh 196323 2496 106963 86864 0.012714
    18 Colombia 165169 6164 71736 87269 0.037319
    19 Argentina 114783 2112 49120 63551 0.018400
    20 Canada 111144 8875 74433 27836 0.079851
    21 Qatar 105477 152 102168 3157 0.001441
    22 Iraq 86148 3522 54316 28310 0.040883
    23 Egypt 85771 4120 26691 54960 0.048035
    24 China 85314 4644 80018 652 0.054434
    25 Indonesia 81668 3873 40345 37450 0.047424
    26 Sweden 76877 5593 0 71284 0.072753
    27 Ecuador 71365 5207 31260 34898 0.072963
    28 Kazakhstan 66895 375 40256 26264 0.005606
    29 Belarus 65623 485 56915 8223 0.007391
    30 Belgium 63238 9795 17253 36190 0.154891
    31 Oman 62574 290 40090 22194 0.004635
    32 Philippines 61266 1643 21440 38183 0.026817
    33 Kuwait 57668 402 47545 9721 0.006971
    34 Ukraine 57640 1462 29822 26356 0.025364
    35 United Arab Emirates 56129 335 47412 8382 0.005968
    36 Bolivia 54156 1984 16979 35193 0.036635
    37 Netherlands 51572 6156 194 45222 0.119367
    38 Panama 50373 1000 25842 23531 0.019852
    39 Dominican Republic 48743 941 23636 24166 0.019305
    40 Portugal 47765 1679 32476 13610 0.035151
    41 Singapore 47126 27 43256 3843 0.000573
    42 Israel 46059 384 20370 25305 0.008337
    43 Poland 39054 1605 28928 8521 0.041097
    44 Bahrain 35084 121 30809 4154 0.003449
    45 Afghanistan 35070 1113 22824 11133 0.031737
    46 Romania 35003 1971 22189 10843 0.056309
    47 Nigeria 34854 769 14292 19793 0.022063
    48 Armenia 33559 607 21931 11021 0.018088
    49 Switzerland 33290 1969 29900 1421 0.059147
    50 Guatemala 32939 1404 4807 26728 0.042624
    51 Honduras 30867 835 3420 26612 0.027052
    52 Azerbaijan 26165 334 17256 8575 0.012765
    53 Ghana 26125 139 22270 3716 0.005321
    54 Ireland 25698 1749 23364 585 0.068060
    55 Japan 23510 985 18641 3884 0.041897
    56 Algeria 21355 1052 15107 5196 0.049262
    57 Moldova 20264 666 13640 5958 0.032866
    58 Serbia 19717 442 14417 4858 0.022417
    59 Austria 19270 711 17244 1315 0.036897
    60 Nepal 17344 39 11249 6056 0.002249
    61 Morocco 16545 263 13965 2317 0.015896
    62 Cameroon 16157 373 13728 2056 0.023086
    63 Uzbekistan 15066 75 8783 6208 0.004978
    64 Korea, South 13672 293 12460 919 0.021431
    65 Czechia 13612 355 8640 4617 0.026080
    66 Cote d'Ivoire 13554 87 7363 6104 0.006419
    67 Denmark 13325 610 12396 319 0.045779
    68 Kyrgyzstan 12498 167 3735 8596 0.013362
    69 Kenya 11673 217 3638 7818 0.018590
    70 Australia 11233 116 8114 3003 0.010327
    71 El Salvador 10957 298 6257 4402 0.027197
    72 Venezuela 10854 104 3255 7495 0.009582
    73 Sudan 10527 668 5601 4258 0.063456
    74 Costa Rica 9546 42 2673 6831 0.004400
    75 Norway 9015 254 8138 623 0.028175
    76 Malaysia 8737 122 8538 77 0.013964
    77 North Macedonia 8623 401 4565 3657 0.046504
    78 Senegal 8481 156 5735 2590 0.018394
    79 Ethiopia 8475 148 2430 5897 0.017463
    80 Congo (Kinshasa) 8199 193 4248 3758 0.023539
    81 Bulgaria 8144 293 3927 3924 0.035977
    82 Bosnia and Herzegovina 7681 240 3534 3907 0.031246
    83 West Bank and Gaza 7412 51 1313 6048 0.006881
    84 Finland 7293 328 6880 85 0.044975
    85 Haiti 6948 145 3606 3197 0.020869
    86 Tajikistan 6741 56 5431 1254 0.008307
    87 Guinea 6359 39 5012 1308 0.006133
    88 Gabon 6121 46 3664 2411 0.007515
    89 Madagascar 6089 53 2951 3085 0.008704
    90 Mauritania 5659 150 2993 2516 0.026506
    91 Luxembourg 5285 111 4275 899 0.021003
    92 Kosovo 5237 112 2462 2663 0.021386
    93 Djibouti 4993 56 4796 141 0.011216
    94 Central African Republic 4373 53 1265 3055 0.012120
    95 Hungary 4279 595 3156 528 0.139051
    96 Croatia 4039 120 2729 1190 0.029710
    97 Greece 3939 193 1374 2372 0.048997
    98 Albania 3851 104 2137 1610 0.027006
    99 Paraguay 3342 27 1379 1936 0.008079
    100 Thailand 3236 58 3095 83 0.017923
    101 Nicaragua 3147 99 2282 766 0.031459
    102 Somalia 3106 93 1444 1569 0.029942
    103 Equatorial Guinea 3071 51 842 2178 0.016607
    104 Maldives 2899 15 2339 545 0.005174
    105 Malawi 2712 51 1073 1588 0.018805
    106 Sri Lanka 2687 11 2007 669 0.004094
    107 Lebanon 2599 40 1485 1074 0.015391
    108 Cuba 2440 87 2285 68 0.035656
    109 Mali 2440 121 1777 542 0.049590
    110 Congo (Brazzaville) 2358 48 589 1721 0.020356
    111 South Sudan 2171 41 1175 955 0.018885
    112 Estonia 2016 69 1904 43 0.034226
    113 Slovakia 1951 28 1514 409 0.014352
    114 Iceland 1914 10 1892 12 0.005225
    115 Guinea-Bissau 1902 26 773 1103 0.013670
    116 Lithuania 1902 79 1593 230 0.041535
    117 Slovenia 1897 111 1522 264 0.058513
    118 Zambia 1895 42 1412 441 0.022164
    119 Cabo Verde 1894 19 902 973 0.010032
    120 Sierra Leone 1678 64 1213 401 0.038141
    121 Libya 1652 46 379 1227 0.027845
    122 Eswatini 1552 21 736 795 0.013531
    123 Yemen 1552 438 695 419 0.282216
    124 New Zealand 1549 22 1506 21 0.014203
    125 Rwanda 1473 4 770 699 0.002716
    126 Benin 1463 28 557 878 0.019139
    127 Mozambique 1383 9 375 999 0.006508
    128 Zimbabwe 1362 23 425 914 0.016887
    129 Tunisia 1327 50 1093 184 0.037679
    130 Montenegro 1287 24 330 933 0.018648
    131 Jordan 1206 10 1019 177 0.008292
    132 Latvia 1179 31 1022 126 0.026293
    133 Niger 1102 69 993 40 0.062613
    134 Liberia 1070 68 486 516 0.063551
    135 Uganda 1051 0 1014 37 0.000000
    136 Burkina Faso 1038 53 882 103 0.051060
    137 Namibia 1032 2 31 999 0.001938
    138 Cyprus 1031 19 845 167 0.018429
    139 Uruguay 1026 32 916 78 0.031189
    140 Georgia 1006 15 883 108 0.014911
    141 Suriname 904 18 581 305 0.019912
    142 Chad 886 75 799 12 0.084650
    143 Andorra 877 52 803 22 0.059293
    144 Jamaica 765 10 647 108 0.013072
    145 Togo 749 15 543 191 0.020027
    146 Sao Tome and Principe 740 14 325 401 0.018919
    147 Diamond Princess 712 13 651 48 0.018258
    148 San Marino 699 42 656 1 0.060086
    149 Malta 674 9 661 4 0.013353
    150 Angola 607 28 124 455 0.046129
    151 Botswana 522 1 48 473 0.001916
    152 Tanzania 509 21 183 305 0.041257
    153 Syria 477 22 140 315 0.046122
    154 Taiwan* 451 7 440 4 0.015521
    155 Vietnam 381 0 356 25 0.000000
    156 Mauritius 343 10 331 2 0.029155
    157 Burma 339 6 270 63 0.017699
    158 Comoros 328 7 311 10 0.021341
    159 Guyana 315 19 156 140 0.060317
    160 Burundi 303 1 207 95 0.003300
    161 Mongolia 262 0 211 51 0.000000
    162 Lesotho 256 3 48 205 0.011719
    163 Eritrea 251 0 149 102 0.000000
    164 Cambodia 171 0 133 38 0.000000
    165 Brunei 141 3 138 0 0.021277
    166 Trinidad and Tobago 133 8 124 1 0.060150
    167 Bahamas 124 11 91 22 0.088710
    168 Monaco 109 4 98 7 0.036697
    169 Seychelles 108 0 27 81 0.000000
    170 Barbados 104 7 90 7 0.067308
    171 Bhutan 86 0 78 8 0.000000
    172 Liechtenstein 84 1 81 2 0.011905
    173 Gambia 78 3 34 41 0.038462
    174 Antigua and Barbuda 74 3 57 14 0.040541
    175 Belize 40 2 22 16 0.050000
    176 Saint Vincent and the Grenadines 35 0 29 6 0.000000
    177 Fiji 26 0 18 8 0.000000
    178 Timor-Leste 24 0 24 0 0.000000
    179 Grenada 23 0 23 0 0.000000
    180 Saint Lucia 23 0 19 4 0.000000
    181 Laos 19 0 19 0 0.000000
    182 Dominica 18 0 18 0 0.000000
    183 Saint Kitts and Nevis 17 0 15 2 0.000000
    184 Holy See 12 0 12 0 0.000000
    185 Papua New Guinea 11 0 8 3 0.000000
    186 Western Sahara 10 1 8 1 0.100000
    187 MS Zaandam 9 2 0 7 0.222222
    In [66]:
    # Only show 15 countries with the most confirmed cases, the rest are grouped into the other category
    visual_unique_countries = [] 
    visual_confirmed_cases = []
    others = np.sum(country_confirmed_cases[15:])
    
    for i in range(len(country_confirmed_cases[:15])):
        visual_unique_countries.append(unique_countries[i])
        visual_confirmed_cases.append(country_confirmed_cases[i])
        
    visual_unique_countries.append('Others')
    visual_confirmed_cases.append(others)
    
    def plot_bar_graphs(x, y, title):
        plt.figure(figsize=(16, 9))
        plt.barh(x, y)
        plt.title(title, size=20)
        plt.xticks(size=20)
        plt.yticks(size=20)
        plt.show()
    
    In [67]:
    plot_bar_graphs(visual_unique_countries, visual_confirmed_cases, '# of Covid-19 Confirmed Cases in Countries/Regions')
    
    In [68]:
    import random
    def plot_pie_charts(x, y, title):
        c = random.choices(list(mcolors.CSS4_COLORS.values()),k = len(unique_countries))
        plt.figure(figsize=(20,15))
        plt.title(title, size=20)
        plt.pie(y, colors=c)
        plt.legend(x, loc='best', fontsize=15)
        plt.show()
    

    Covid19 confirmed cases per country:

    In [70]:
    plot_pie_charts(visual_unique_countries, visual_confirmed_cases, 'Covid-19 Confirmed Cases per Country')
    

    PROTECTIVE MEASUREMENT

  • It is very necessity to wash frequently your hands for 20 seconds with cleanser and water or alcohol founded scrub.
  • We need to our face with disposable face mask.
  • We need to avoid close contact (1 m) from those peoples who have effected by corona virus
  • We need to not touch face if our hands are not hygienic.


  • </font>

    TREATMENTS

    There are currently no vaccine for Corona virus but according to my point of view we can cure the Corona diseases by using some plants.
    If you find coronal diseases in yourself then you easily cure this diseases by using some plants.
    Practically I have proved that by using these plants to control Pneumonia diseases.

    </font>